# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: yield表达式练习.py
Author: kij
Create Date: 2021/2/14
-------------------------------------------------
"""


def dog(name):
	food_list2 = []
	print("名叫%s的狗狗" % name)
	while True:

		food = yield food_list2  # yield后面可以跟返回值 yield 是新的yield 不是同一个
		print('名叫%s的狗狗吃了%s' % (name, food))
		food_list2.append(food)

g = dog('豆豆')
g.send(None)  # 等同于next(g) 不写这个会报错，相当于初始化
food_list = ['肉', '馒头', '方便面']
res = g.send('肉')
print(res)
# g.close()  # 关闭之后不再运行
res = g.send('馒头')
print(res)
res = g.send('方便面')
print(res)
